unit DicOtdel;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  AbstDictionary, ActnList, Db, ExtCtrls, Grids, DBGrids, Buttons;

type
  TfmDicOtdel = class(TfmAbstDictionary)
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function Kod_otd(BBK: string): integer;

var
  fmDicOtdel: TfmDicOtdel;

implementation
uses SpisCnst, ModifyOtdel;
{$R *.DFM}

function Kod_otd(BBK: string): integer;
var
  d1, d2: integer;
begin
  result := 0;
  if BBK = '' then Exit;
  d1 := StrToInt(BBK[1]);
  d2 := StrToInt(Copy(BBK, 1, 2));
  if (d1 in [1,6,7,8,9]) then result := 1;
  if (d1 in [2,5]) then result := 2;
  if (d1 in [3,4]) then result := 3;
  if (d2 in [75,85]) then result := 4;
  if (d2 in [80,81,82,83,84]) then result := 5;
end;

procedure TfmDicOtdel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  Parent := nil;
end;

procedure TfmDicOtdel.FormDestroy(Sender: TObject);
begin
  inherited;
  fmDicOtdel := nil;
end;

procedure TfmDicOtdel.FormCreate(Sender: TObject);
begin
  inherited;
  MandatoryField:='KOD_OT';
  ModifyClass := TfmModifyOtdel;
  setTableID(dtOtdel);
  if ((Owner is TForm) AND (TForm(Owner).FormStyle = fsMDIForm)) then begin
    FormStyle := fsMDIChild;
  end;
end;

end.
